#include <connection.h>

#include "sqlpool.h"

AsudConnectionPool::AsudConnectionPool(const std::string &_server, const std::string &_user, const std::string &_password, const std::string &_db):
    db_(_db),
    server_(_server),
    user_(_user),
    password_(_password)
{
}

AsudConnectionPool::~AsudConnectionPool()
{
    clear();
}

mysqlpp::Connection *AsudConnectionPool::create()
{
    return new mysqlpp::Connection( db_.c_str(), server_.c_str(), user_.c_str(), password_.c_str());
}

void AsudConnectionPool::destroy( mysqlpp::Connection *con )
{
    delete con;
}

unsigned int AsudConnectionPool::max_idle_time()
{
    return 20;          //  TODO: read from config
}

